using System;
using System.IO;
using System.Xml;

namespace WxLib.Model
{
    public class RedirectReturn
    {
        public RedirectReturn(string xmlReturn)
        {
            using (StringReader reader = new StringReader(xmlReturn))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);

                XmlNodeList roots = doc.ChildNodes;
                if (null == roots || 0 == roots.Count)
                {
                    throw new ArgumentException(xmlReturn);
                }

                foreach (XmlNode node in roots[0].ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "ret":
                            Ret = node.InnerText;
                            break;
                        case "message":
                            Message = node.InnerText;
                            break;
                        case "skey":
                            Skey = node.InnerText;
                            break;
                        case "wxsid":
                            WxSid = node.InnerText;
                            break;
                        case "wxuin":
                            WxUin = node.InnerText;
                            break;
                        case "pass_ticket":
                            PassTicket = node.InnerText;
                            break;
                        case "isgrayscale":
                            IsGrayScale = node.InnerText;
                            break;
                        default: break;
                    }
                }
            }
        }
        public string Ret { get; set; }
        public string Message { get; set; }
        public string Skey { get; set; }
        public string WxSid { get; set; }
        public string WxUin { get; set; }
        public string PassTicket { get; set; }
        public string IsGrayScale { get; set; }
    }
}